package com.haralabidis.jdeveloper.extension.subversionmonitor.addin;

import com.haralabidis.jdeveloper.extension.subversionmonitor.addin.preferences.SubversionMonitorPreferences;

import oracle.ide.Addin;
import oracle.ide.Ide;
import oracle.ide.IdeEvent;
import oracle.ide.IdeListener;
import oracle.ide.config.Preferences;
import oracle.ide.extension.RegisteredByExtension;
import oracle.ide.model.Recognizer;


@RegisteredByExtension("com.haralabidis.jdeveloper.extension.subversionmonitor.addin")
final class SubversionMonitorAddin implements Addin {

    public static SubversionMonitor monitor = new SubversionMonitor();

    public void initialize() {
        Ide.addIdeListener(new IdeListener() {
                public void addinsLoaded(IdeEvent ideEvent) {
                }

                public void mainWindowClosing(IdeEvent ideEvent) {
                }

                public void mainWindowOpened(IdeEvent ideEvent) {
                    
                    Recognizer.mapExtensionToClass("submon", SubversionMonitorNode.class);
                    SubversionMonitorPreferences preferences = SubversionMonitorPreferences.getInstance(Preferences.getPreferences());
                    monitor.init(preferences.getSubversionUrl(),
                                 preferences.getSubversionUser(),
                                 preferences.getSubversionPassword(),
                                 !preferences.getMonitorDisabled(),
                                 preferences.getMonitorTimeout());
                }
            });
    }
}
